import service from "@/service";

//根据用户登录id查询所有租户
export function getTenantByUid(parameter) {
  let { userId } = parameter;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-tenant/getByUserId?userId=${userId}`,
    method: "POST",
  });
}

//查询租户对应项目列表
export function getProjectListByUserIdAndTenant(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-project/getByUserIdAndTenant`,
    method: "POST",
    data: parameter,
  });
}

// 根据用户id+租户编码查询所有有权限菜单（包含页面和按钮，树形）
export function getPermissionByUserIdAndTenant(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-tenant-permission/getByUserIdAndTenantPCNew`,
    method: "POST",
    data: parameter,
  });
}

//刷新token
export function tokenRefresh(parameter) {
  let { userId } = parameter;
  return service({
    url: `/auth/oauth/tokenRefresh?userId=${userId}`,
    baseUrl: "gateWaybaseUrl",
    method: "POST",
    isAuthorization: false,
  });
}

//登录【获取token】
export function getAuthData(data) {
  return service({
    url: `/auth/oauth/token`,
    method: "POST",
    isAuthorization: false,
    auth: {
      username: "jsbj-admin",
      password: "123456",
    },
    data,
  });
}

// 修改密码接口
export function updatePassword(params) {
  return service({
    url: `/user/sys-user/api/updatePassword`,
    method: "POST",
    baseUrl: "gateWaybaseUrl",
    data: params,
  });
}

export function getTripartiteData(params) {
  let { token } = params;
  return service({
    url: `/auth/useraccess/callback?user_token=${token}`,
    method: "GET",
    isAuthorization: false,
  });
}
